<cfparam name="url.vw" default="">
<cfset id = URLDecode( Decrypt( url.vw, client.ek ) ) >
<cfset isPosted = FALSE>

<cfquery name="getDtls" datasource="#client.company_dsn#">
	SELECT WS.DATEFROM, WS.DATETO, DP.DESCRIPTION, WS.APPROVED
    FROM CINWSFILE WS
    LEFT JOIN CLKDEPARTMENT DP ON DP.DEPARTMENTCODE = WS.DEPTCODE
    WHERE DOCNUMBER = '#ID#'
</cfquery>

<cfif Len(getDtls.APPROVED)>
	<cfif getDtls.APPROVED eq 'Y'>
    	<cfset isPosted = TRUE>
    </cfif>
</cfif>
<CFQUERY NAME="getPowerUser" DATASOURCE="#client.company_dsn#">
    SELECT Count(PERSONNELIDNO) AS COUNT
    FROM CINWSPOWERUSER 
    WHERE PERSONNELIDNO ='#client.chapa#'
</CFQUERY>

<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="Work Schedule Information&nbsp;&nbsp;">
<table>
	<tr>
    	<td>DEPARTMENTAL DUTY SCHEDULE</td>
    </tr>
<cfoutput>
    <tr>
        <td>FOR THE PERIOD <b>#DateFormat( getDtls.DATEFROM, "MMM DD" )#</b> TO 
        <b>#DateFormat( getDtls.DATETO, "MMM DD" )#</b></td>
    </tr>
    <tr>
        <td colspan="2" align="left"><B>DEPARTMENT&nbsp;:&nbsp;#getDtls.DESCRIPTION#</B></td>
    </tr>
    <CFIF isPosted>
        <tr>
            <td colspan="2" align="left">
                <span style="color:F00">THIS FORM IS ALREADY POSTED</span>
            </td>
        </tr>
    </CFIF>
</cfoutput>
    
</table>
<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">

<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="Select Action">
<cfscript>
	min = DateFormat( getDtls.DATEFROM, "YYYY-MM-DD" );
	max = DateFormat( getDtls.DATETO, "YYYY-MM-DD" );
</cfscript>


<FORM action="../manning/index.cfm" method="post"> 
  <div style="text-align:left">
  		<input type="submit" name="back" value="Back" style ="width:70px" class="bitbtn"/>&nbsp;&nbsp;
        <cfif getPowerUser.Count and not isPosted>
        <input type="button" name="sRoute" value="Post" style ="width:70px" 
        	class="bitbtn" onclick="javascript:postWorksked()"/>
        </cfif>
        <input type="hidden" value="<cfoutput>#max#</cfoutput>" name="max" id="max" />
        <input type="hidden" value="<cfoutput>#min#</cfoutput>" name="min" id="min" />
        <input type="hidden" value="<cfoutput>#id#</cfoutput>" name="docno" id="docno" />
        <cfset Request.encdocno = url.vw>
  </div>
</FORM>  

<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">

<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="Simulation History">

<cfdiv id="simHist" bind="url:_getHist.cfm?id=#id#" bindonload="yes"/>

<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">
<form name="sFormViewDys"
<cfset min = DateAdd("d",-1,min)>
<cfset rows = 6> 
<cfloop condition="#min# lt #max#">
	
	<cfset st = DateAdd("d",1,min)>
	<cfif DateAdd("d",rows,min) lte max>
		<cfset min = DateAdd("d",rows,min) >     	
    <cfelse>
    	<cfset min = max>
    </cfif>
    
    <cfscript>
		st = DateFormat( st, "YYYY-MM-DD" );
		min = DateFormat( min, "YYYY-MM-DD" );
	</cfscript>
    
    <CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" 
    	TITLE="Work Schedule: #DateFormat(st,'MMM. DD, YYYY')# to #DateFormat(min,'MMM. DD, YYYY')#&nbsp;&nbsp;">
    <cfset err = true>
    
   
    <cfloop condition="#err#">
    	<cftry>
        	<cfdiv bindonload="yes" bind="url:viewRec.cfm?from=#st#&to=#min#&vw=#id#" />
            <cfset err = false> 
        <cfcatch>
           	 <cfset err = true> 
        </cfcatch>
        </cftry>
    </cfloop>
    
   
    <CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">
    
	
</cfloop>
</form>
<cfset AjaxOnLoad("init()")> 

